package com.zhengxin.web;

import java.util.List;

import com.zhengxin.pojo.Customer;
import com.zhengxin.pojo.Employee;
import com.zhengxin.pojo.TraceHistory;
import com.zhengxin.pojo.TransferHistory;
import com.zhengxin.utils.UserContext;

public class TransferHistoryAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Customer customer;
	
	private TransferHistory transferHistory;
	
	private TraceHistory traceHistory;
	
	public TraceHistory getTraceHistory() {
		return traceHistory;
	}
	
	public void setTraceHistory(TraceHistory traceHistory) {
		this.traceHistory = traceHistory;
	}
	
	public TransferHistory getTransferHistory() {
		return transferHistory;
	}

	public void setTransferHistory(TransferHistory transferHistory) {
		this.transferHistory = transferHistory;
	}
	
	public Customer getCustomer() {
		return customer;
	}
	
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public String viewEdit(){
		if(customer != null){
			customer=customerService.findByid(customer.getId());
		}
		//查询所有的营销人员(在jsp页面中用户选择)
		List<Employee> list=employeeService.getAll();
		request.put("listEmployee", list);
		return "edit";
	}
	
	//保存
	public String save(){
		//要移交的客户
		transferHistory.setCustomer(customer);
		//旧的营销人员
		transferHistory.setOddSeller(UserContext.get());
		transferHistoryService.save(transferHistory);
		return "save";
	}
	
	//列表展示方法
	public String list(){
		List<TransferHistory> listTransferHistory=transferHistoryService.getAll();
		request.put("listTransferHistory", listTransferHistory);
		return "list";
	}
}
